<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=872660759419047&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<style type="text/css">
.replated ul{margin:0px;padding:0px}
.replated ul li{width:47%;list-style:none;border:1px solid #CCC;padding:10px;margin:10px;float:left}
.replated ul li p{margin:0px}
.replated ul li img{float:left;width:35%;margin-right:5px;border:1px solid #CCC}
.tags .title-tags{font-weight:bold}
.box_content img{border:none}
</style>
<!-- right -->
<div class="col-md-9">            	
    <?php echo $this->load->view('breadcrumb', FALSE);?>
    <div class="title_article">
        <h3><i class="fa fa-file-text"></i> Bài viết</h3>
    </div>
    <div class="aricle_wp">
        <div class="box_blog box_blog_detail">
            <h3><a href="#"><?php echo $news_detail->title;?></a></h3>
            <div>
            <div style="float:left;margin-bottom:15px;margin-right:25px" class="date_wp">Ngày đăng <?php echo date('d/m/Y',$news_detail->created);?>, có <?php echo 1+$news_detail->count_view?> lượt xem.</div>
            <div style="float:left" class="fb-like" data-href="<?php echo site_url(uri_string())?>" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>
            <div style="clear:both"</div>
            </div>
            <?php echo html_entity_decode($news_detail->bodyhtml);?>
			<?php if(!empty($tags)){?> 
				<div class='tags'>
                	<span class="title-tags">Tags:</span>
					<?php $i =0; foreach($tags as $item){$i++?>
					<span class="item-tags"><?php echo ($i!=1)?', ':"";echo "<a href='".site_url("blog/tags/".$item->slug)."'>".$item->name."</a>"?></span>
					<?php }?>
                </div>
			<?php }?>
            <?php if(!empty($product)){?>
            <div class="box_content" style="margin-top:15px;">
                	<div class="title_head khuyendung_wp_title" style="padding-left:15px;">
                    	<h3 style="color:#FFF"> Sản phẩm khuyên dùng</h3>
                    </div>
                    <div class="home_product_wp">
						<ul class="box_product_ul">
							<?php $i=0; foreach($product as $item){if($i++ < 4){?>
                            <li class="box_product_li col-xs-12 col-sm-6 col-md-3">                            	
								<div class="box_product_wp">
                                    <div class="product_image">
                                    	<?php if(!empty($item->active_docquyen))echo '<div class="rolate_image">Độc quyền</div>'?>
                                    	<?php $photo  = theme_img('no_picture.png', lang('no_image_available'));
                        				$item->images    = array_values((array)json_decode($item->images));
                                    	if(!empty($item->images[0]))
                                        {
                                            $primary    = $item->images[0];
                                            foreach($item->images as $photo)
                                            {
                                                if(isset($photo->primary))
                                                {
                                                    $primary    = $photo;
                                                }
                                            }
                
                                            $photo  = '<img src="'.base_url('uploads/images/thumbnails/'.$primary->filename).'" alt="'.$item->seo_title.'"/>';
                                       }?>
                                    	<a href="<?php echo site_url($item->cat_slug.'/'.$item->slug);?>"><?php echo $photo;?></a>
                                         <?php if($item->quantity <= 0)echo ' <div class="product_status"><div class="info_status_product">Sản phẩm đang về</div><div class="backgroup_opacity"></div></div>'?>
                                    </div>
                                    <div class="product_text">
                                    	<h3><a href="<?php echo site_url($item->cat_slug.'/'.$item->slug);?>"><?php echo $item->name?></a></h3>
                                        <p><?php echo $item->excerpt?></p>
                                    </div>
                                    <div class="product_price">
                                    	<!--<p class="red">1.000.000 <span>VNĐ</span></p>-->
                                        <p class="red">
											<?php 
												if(!empty($price_products_chuluc[$item->id])){
													echo format_currency($price_products_chuluc[$item->id]);
												}else{
												  if($item->saleprice > 0)
													echo format_currency($item->saleprice);
                                            	  else 
												  	echo format_currency($item->price);
												}?>
                                        </p>
                                        <div class="button_cart">
                                        	<?php echo form_open('cart/add_to_cart', 'class="form-horizontal"');?>
                                            <input type="hidden" name="cartkey" value="<?php echo $this->session->flashdata('cartkey');?>" />
                                            <input type="hidden" name="id" value="<?php echo $item->id?>"/>
                                            <?php if($item->quantity > 0){?> <button class="button-shopping-cart" type="submit" value="submit"><i class="fa fa-shopping-cart"></i></button><?php }?>
                                            </form>
                                        </div>
                                    </div>
								</div>
							</li>
                            <?php }}?>
						</ul>
                        <div class="clear"></div>
                    </div>
                </div>
            <?php }?>
            <?php  if(!empty($related_blogs)){?>
            <p style="border-top:1px solid #CCC; margin-top:20px; margin-bottom:10px"><h3><a>Bài viết khác</a></h3></p>
            <div class="replated">
            	<?php echo '<ul>';foreach($related_blogs as $item){?>
            		<li><p> <img  src="<?php echo base_url('uploads/images/thumbnails/blogs/'.$item->image);?>" /></p><p><a href="<?php echo site_url(BLOGS_DETAIL.$item->slug);?>" sl-processed="1"><?php echo $item->title;?></a></p></li>
                <?php }echo '</ul><div class="clear"></div>';?>
            </div>
            <?php }?>

            <p style="border-top:1px solid #CCC; margin-top:20px; margin-bottom:10px"><h3><a>Bình luận</a></h3></p>
            <div class="fb-comments" data-href="<?php echo site_url($this->uri->uri_string())?>" data-numposts="15" data-colorscheme="light" data-width="100%"></div>            
        </div>
    </div>
</div>